package main.java.design.flyweight;

/**
 * <p>
 *     享元模式
 * </p>
 *
 * @author : wangdejian
 * @version 1.0
 * @date : 2020/6/15 21:55
 */
public class Client {

    public static void main(String[] args) {
        FlyweightFactory factory = new FlyweightFactory();
        Flyweight flyweight = factory.getWeiqiFlyweight("白色");
        Position position = new Position( 3, 5);

        flyweight.playGo(position);

        Flyweight flyweight2 = factory.getWeiqiFlyweight("黑色");
        Position position2 = new Position( 4, 5);

        flyweight2.playGo(position2);

        Flyweight flyweight3 = factory.getWeiqiFlyweight("白色");
        Position position3 = new Position( 6, 5);

        flyweight3.playGo(position3);

        Flyweight flyweight4 = factory.getWeiqiFlyweight("黑色");
        Position position4 = new Position( 5, 5);

        flyweight4.playGo(position4);

        System.out.println("map大小:" + factory.getCount());

    }
}
